import Vue from 'vue'
import Router from 'vue-router'
import Login from '../views/Login'
import Index from '../views/Index/Index'
import RightManage from '../views/Rights/RightManage'
import RoleManage from '../views/Rights/RoleManage'
import ActionRightTest from '../views/Rights/ActionRightTest'
import UserEdit from '../views/User/UserEdit'
import UserManage from '../views/User/UserManage'
import ResourceList from '../views/Resource/ResourceList'

Vue.use(Router)

let router = new Router({
  routes: [
    {
      path: '/',
      redirect: '/index'
    },
    {
      component: Login,
      name: 'Login',
      path: '/login'
    },
    {
      component: Index,
      name: 'Index',
      path: '/index',
      children: [
        {
          component: RightManage,
          name: 'RightManage',
          path: '/rights/manage'
        }, {
          component: RoleManage,
          name: 'RoleManage',
          path: '/rights/roles'
        }, {
          component: ActionRightTest,
          name: 'ActionRightTest',
          path: '/rights/test'
        },
        {
          component: UserEdit,
          name: 'UserEdit',
          path: '/users/edit'
        },
        {
          component: UserManage,
          name: 'UserManage',
          path: '/users/manage'
        },
        {
          component: ResourceList,
          name: 'ResourceList',
          path: '/shares/manage'
        }
      ]
    }
  ]
})

// // 配置全局路由守卫
// router.beforeEach((to, from, next) => {
//   // 进入my组件之前进行判断是否登录
//   // 否，跳转到登录组件
//   if (to.path === '/my') {
//     return next('/login')
//   }
//   console.log('from：' + from.path)
//   console.log('to：' + to.path)
//   //  接下来
//   next()
// })
export default router
